#ifndef LEDVIEW_H
#define LEDVIEW_H
#include <QPainter>
#include <QWidget>
#include <QEvent>
#include <QGraphicsItem>

class ScreenPresentation;

class LedView : public QGraphicsItem
{
	int _x;
	int _y;
	QColor _col;
	int _startAngle;
	int _angleWidth;
	int _radius;
	QWidget* _parent;
	bool _hover;
	bool _active;
	QPoint _pointCenter;
	QPoint _gridPos;
	ScreenPresentation* _mainWidget;
	int _headLed;
	bool _selectable;

public:
	LedView();
	LedView(int x, int y, int radius, int startAngle, int angleWidth, QWidget* parent = 0);
	void setColor(QColor col);
	void setMainWidget(ScreenPresentation* screen);

	QRectF boundingRect() const;
	QPainterPath shape() const;
	void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
	void setPosition(int x, int y);
	void setDirection(int angle);
	void setAngleWidth(int width);
	void setGridPos(QPoint pt) {_gridPos = pt;}
	QPoint getGridPos() {return _gridPos;}
	QColor getColor() {return _col;}
	void setRadius(int radius);
	bool isLedActive();
	void setStart(bool start);
	bool isLedStart() {return _headLed;}
	bool isSelectable() {return _selectable;}
	void setSelectable(bool sel) {_selectable = sel;}

private:
	void drawLight(QPainter* painter);
	void drawPoint(QPainter* painter);
	void drawLightSelection(QPainter* painter);
	void drawPointSelection(QPainter* painter);

protected:
	void hoverEnterEvent(QGraphicsSceneHoverEvent *event);
	void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);
	void mousePressEvent(QGraphicsSceneMouseEvent *event);

public slots:
	//void onMouseHover(QEvent::Type type, const QPoint & pos, const QPoint & oldPos);
};

#endif // LEDVIEW_H
